package cn.i7baozh.consul.controller;

import cn.i7baozh.api.entities.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author : baoqi.zhang
 * @date :   2022/4/6 16:07
 */
@RestController
@Slf4j
public class PaymentConsulController {

    @Value("${server.port}")
    private String serverPort;

    @RequestMapping("/payment/consul")
    public String paymentConsul(){
        return "spring cloud with consule " + serverPort + " " +UUID.randomUUID().toString();
    }
    @RequestMapping("/payment/timeout")
    public String paymentTimeout(){
        log.info("request timeout url");
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "spring cloud with consule timeout 3s" + serverPort + " " +UUID.randomUUID().toString();
    }
    @RequestMapping("/payment/abc")
    public CommonResult<String> abc() {
        return new CommonResult<>(200, "ok", "大家好啊" + serverPort);
    }
}
